# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libcpuid
pkgver=0.6.4
pkgrel=0
pkgdesc="C library for x86 CPU detection and feature extraction"
url="https://github.com/anrieff/libcpuid"
arch="x86 x86_64"
license="BSD-2-Clause"
makedepends="cmake samurai"
checkdepends="python3"
subpackages="$pkgname-dev $pkgname-tool"
source="https://github.com/anrieff/libcpuid/releases/download/v$pkgver/libcpuid-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DLIBCPUID_TESTS="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ninja -C build test-old
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tool() {
	pkgdesc="$pkgdesc (CLI tool)"

	amove usr/bin
}

sha512sums="
4b31abc695a5fcaf88860363d02337bf22091d68db364b3b92b21ff7f51bbd09a05dcfbb97fe05581056aa1e6aad0306aac1ac71d27a50570a1303e03b12476a  libcpuid-0.6.4.tar.gz
"
